home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: jhewett@ix.netcom.com (Jerry Hewett)
- Newsgroups: comp.lang.c++
- Subject: Re: Button Problem???
- Date: Mon, 08 Apr 96 16:32:50 GMT
- Organization: Netcom
- Message-ID: <N.040896.093250.56@ix.netcom.com>
- References: <4k5v31$7rs@newsbf02.news.aol.com>
- NNTP-Posting-Host: tem-ca1-18.ix.netcom.com
- X-NETCOM-Date: Mon Apr 08 11:33:21 AM CDT 1996
- X-Newsreader: Quarterdeck Message Center [2.00]
-
- > I have a Visual C++ 1.52 MFC project that uses buttons in a CFormView. How
- > can I make a button toggle on/off every time it's pressed.
-
- Unless there's a new kind of custom control for pushbuttons in the MFC, you'll
- have to either use another control (a radio button or check box, for example)
- or design your own OWNERDRAW pushbutton. As far as I know, the standard
- pushbutton will only stay down while you're click-select on it, and will always
- "pop" back up when you click-release the mouse.
-
- You can find an example of an OWNERDRAW pushbutton in Chapter 6 of _Programming
- Windows 3.1_ and/or Chapter 8 of _Programming Windows 95_ by Charles Petzold
- (Microsoft Press).
-
- Hmmm... hold on a second! This looks promising. I was thumbing through Part
- One of the MFC Reference and came across CButton::SetBitmap on page 132, which
- contains the following under the REMARKS section:
-
- "Unlike CBitmapButton, which uses four bitmaps per button, SetBitmap
- uses only one bitmap per button. When the button is pressed, the
- bitmap appears to shift down and to the right."
-
- Ah-ha! Take a look at CBitmapButton on pages 112-113! There *is* a new custom
- control, with a step-by-step guide on how to include CBitmapButton's in you
- dialog and instructions on how to change the button state between UP, DOWN,
- FOCUSED, and DISABLED.
-
- Edit your dialog box with the Resource Editor, and add BS_PUSHLIKE to the
- button's parameter list. In theory (since I'm just reading the instructions
- and not writing a sample program to test it :-) this should allow Windows 95 to
- control the pushbutton's appearance. The first time you click-select the
- pushbutton Win95 will change it to a DOWN state, and the next time it's clicked
- it should return to the UP state. For absolute control over the pushbutton's
- appearance you might have to add routines to handle BM_GETSTATE and BM_SETSTATE
- in your button class.
-
- Huh! I learned something new today! 8-)
-
- Jerry ("Not An MFC Guru. Yet") H.
-
-
-